/**
 * 文件：ChoiceView.java
 * 包名：com.ronri.list.editview.controls;   --- 正式发布时需要修正
 * 说明：单选或多选的ItemView
 * 作者：MS During
 * 日期：2017/5/4
 * 历史：
 */
package com.ronri.list.editview.controls;

import android.content.Context;
import android.view.View;
import android.widget.Checkable;
import android.widget.FrameLayout;
import android.widget.RadioButton;
import android.widget.TextView;

import com.cz.nongyetongv5.R;


public class ChoiceView extends FrameLayout implements Checkable {

    private TextView mTextView;
    private RadioButton mRadioButton;

    /***
     * 构造函数
     * @param context
     */
    public ChoiceView(Context context) {
        super(context);
        View.inflate(context, R.layout.item_single_choice, this);
        mTextView = (TextView)findViewById(R.id.text);
        mRadioButton = (RadioButton)findViewById(R.id.checkedView);
    }

    public void setText(String text) {
        mTextView.setText(text);
    }

    @Override
    public void setChecked(boolean checked) {
        mRadioButton.setChecked(checked);
    }

    @Override
    public boolean isChecked() {
        return mRadioButton.isChecked();
    }

    @Override
    public void toggle() {
        mRadioButton.toggle();
    }
}
